import Vuex from "Vuex";
import Vue from "vue";
Vue.use(Vuex);

export default new Vuex.Store({
  // 注意Store的S大写
  state: {
    count: 100
  },
  getters: {
    count: (state, getters, rootState) => {
      return state.count;
    }
  },
  mutations: {
    addCount(state) {
      // mutate state
      state.count++;
    }
  },
  actions: {
    addCount(context) {
      context.commit("addCount");
    }
  }
});
